//
//  MoblieViewController.m
//  dongfengTest
//
//  Created by wxt on 2021/3/24.
//

#import "MoblieViewController.h"
#import "CodeViewController.h"
@interface MoblieViewController ()<UITextFieldDelegate,NoNetworkViewDelegate>
@property(nonatomic,strong)TKLtextFiled * phoneFiled;

@property(nonatomic,strong)TKLlable * messageLab;
@property(nonatomic,strong)UIView * messageView;

@end

@implementation MoblieViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    UIButton * backBtn =[UIButton createBtnFrame:CGRectMake(15, kStatusBarHeight+5, 18, 18) title:@"" bgImageName:@"fanhui" action:^(UIButton *button) {
        
        [self dismissViewControllerAnimated:YES completion:nil];
    }];
//    [self.view addSubview:backBtn];
    
    
    //是否有返回
    TKLlable * navTit = [TKLlable labelWithFrame:CGRectMake(kWidth/2-60, kStatusBarHeight+5, 120, 20) text:@"" textColor:Bcolor font:Font_6(16) textAlignment:Textcenter backgroundColor:Ccolor];
    [self.view addSubview:navTit];
    
    if ([self.pushPath isEqualToString:@"newCer"]||[self.pushPath isEqualToString:@"newUser"]||[self.pushPath isEqualToString:@"timeCer"]) {
        navTit.text = @"设置支付密码";
    }else{
        navTit.text = @"找回登录密码";
    }
    // Do any additional setup after loading the view.
    [self  loadUIView];
  
}
-(void)loadUIView{

    
    TKLlable * lognLab = [TKLlable labelWithFrame:CGRectMake(30, 180, kWidth-60, 30) text:@"请填写你在系统预留的手机号" textColor:JhColor(51, 51, 51) font:Font_6(24) textAlignment:Textleft backgroundColor:Ccolor];
    
    lognLab.font = [UIFont fontWithName:@"Arial-BoldMT" size:18];

    [self.view addSubview:lognLab];
    //提示信息
    self.messageLab = [TKLlable labelWithFrame:CGRectMake(30, CGRectGetMaxY(lognLab.frame)+30, kWidth-60, 14) text:@"" textColor:[UIColor redColor] font:Font_6(12) textAlignment:Textleft backgroundColor:Ccolor];
    self.messageLab.hidden = YES;
    [self.view addSubview:self.messageLab];
    
    
    
    self.phoneFiled = [TKLtextFiled FiledWithFrame:CGRectMake(30, CGRectGetMaxY(lognLab.frame)+50,kWidth-60 , 20) text:@"请输入手机号" textColor:JhColor(51, 51, 51) font:Font_6(14) textAlignment:Textleft backgroundColor:Ccolor];
    self.phoneFiled.keyboardType = UIKeyboardTypeNumberPad;
    self.phoneFiled.delegate = self;
    [self.phoneFiled addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    [self.view addSubview:self.phoneFiled];
    
    self.messageView = [[UIView alloc]initWithFrame:CGRectMake(30, CGRectGetMaxY(self.phoneFiled.frame)+10, kWidth-60, 1)];
    self.messageView.backgroundColor = JhColor(153, 153, 153);
    [self.view addSubview:self.messageView];
    //next
    UIButton * nextBtn = [UIButton createBtnFrame:CGRectMake(30, CGRectGetMaxY(self.messageView.frame)+20, kWidth-60, 44) title:@"下一步" bgImageName:@"" action:^(UIButton *button) {
        
        
        
        if ([TKLTools isMobileNumber:self.phoneFiled.text]) {
            CodeViewController * codeVC = [[CodeViewController alloc]init];
            
            codeVC.phoneNumberStr = self.phoneFiled.text;
            codeVC.pushPath = self.pushPath;
            codeVC.userName = self.userName;
            codeVC.modalPresentationStyle = 0;
            [self presentViewController:codeVC animated:YES completion:nil];
        }else{
            
            [MBProgressHUD showError:@"请输入正确的手机号" toView:self.view];
            
        }

        
        
    }];
//    nextBtn
    nextBtn.backgroundColor = JhColor(21, 126, 251);
    nextBtn.layer.masksToBounds = YES;
    nextBtn.layer.cornerRadius = 5;
    [self.view addSubview:nextBtn];
    
    
    TKLlable * messlab = [TKLlable labelWithFrame:CGRectMake(30, CGRectGetMaxY(nextBtn.frame)+10, kWidth-60, 20) text:@"若手机号有变请联系管理员" textColor:JhColor(204, 204, 204) font:Font_6(14) textAlignment:Textcenter backgroundColor:Ccolor];
    [self.view addSubview:messlab];
    

    
    
}
- (void)textFieldDidChange:(UITextField *)textField{
   
    if (textField == self.phoneFiled) {
        if (textField.text.length > 11) {
            self.phoneFiled.text = [textField.text substringToIndex:11];
        }
    }

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
